How to count number of words in a string in java